package com.sf.osms.dep.domain;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.dozer.Mapping;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;

import com.sf.novatar.base.domain.LongIdBean;

@Entity
@Table(name = "wbs_tt_router_tmp")
@Polymorphism(type = PolymorphismType.EXPLICIT)
public class RouterTmp extends LongIdBean implements java.io.Serializable{

	private static final long serialVersionUID = 1L;
	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	private Long id; 
	/**
	 * 代理ID
	 */
	@Column(name = "AGENT_ID")
	private Long agentId;
	/**
	 * 代理国家
	 */
	@Column(name = "COUNTRY")
	private String country;
	/**
	 * 顺丰的waybill
	 */
	@Column(name = "SF_WAYBILL")
	@Mapping("waybillNo")
	private String sfWaybill; 
	/**
	 * 代理代码
	 */
	@Column(name = "AGENT_CODE")
	private String agentCode; 
	/**
	 * 代理的waybill
	 */
	@Column(name = "AGENT_WAYBILL")
	private String agentWaybill; 
	/**
	 * 代理网点号
	 */
	@Column(name = "NET_NUM")
	@Mapping("zoneCode")
	private String netNum;
	
	/**
	 * 代理
	 */
	@Transient
	private String agentNetNum;
	
	/**
	 * 操作员工号
	 */
	@Column(name = "OPERATOR_ID")
	@Mapping("barOprCode")
	private String operatorId; 
	/**
	 * 顺丰的事件节点
	 */
	@Column(name = "EVENT_CODE")
	@Mapping("opCode")
	private Integer eventCode; 
	/**
	 * 事件节点的原因
	 */
	@Column(name = "REASON_CODE")
	@Mapping("stayWhyCode")
	private Integer reasonCode; 
	/**
	 * 把枪扫描日期
	 */
	@Column(name = "BAR_DATE")
	@Mapping("barScanDt")
	private Date barDate;
	/**
	 * 把枪扫描时间
	 */
	@Column(name = "BAR_TIME")
	private Date barTime; 
	/**
	 * 上传类型
	 */
	@Column(name = "BAR_UPLOAD_TYPE_CODE")
	@Mapping("barUploadTypeCode")
	private Long barUploadTypeCode;
	/**
	 * 收派员，接驳员工号（不同节点代表含义不同）
	 */
	@Column(name = "COURIER_CODE")
	@Mapping("courierCode")
	private String courierCode;
	/**
	 * 加密串
	 */
	@Column(name = "ENCRYPT_STRING")
	@Mapping("encryptString")
	private String encryptString;
	/**
	 * 把枪设备号
	 */
	@Column(name = "BAR_SN")
	@Mapping("barSn")
	private String barSn;
	/**
	 * 批次，电子卷号（不同节点代表含义不同）
	 */
	@Column(name = "BATCH_CODE")
	@Mapping("batchCode")
	private String batchCode;
	/**
	 * 跨境线路标识
	 */
	@Column(name = "OP_NAME")
	@Mapping("opName")
	private String opName;
	/**
	 * 线路编码，线路，目的地代码(不同节点代表含义不同)
	 */
	@Column(name = "OP_ATTACH_INFO")
	@Mapping("opAttachInfo")
	private String opAttachInfo;
	/**
	 * 容器编号（包/袋/车号）(不同号码生成的格式不同)
	 */
	@Column(name = "CONTNR_CODE")
	@Mapping("contnrCode")
	private String contnrCode;
	/**
	 * 落地配装车标识，批量出仓标记，目的地代码，割箱标识（不同节点含义不同）
	 */
	@Column(name = "PHONE_ZONE")
	@Mapping("phoneZone")
	private String phoneZone;
	/**
	 * 口岸识别码，收方电话，电话号码，稽核标识(不同节点的代表含义不同)
	 */
	@Column(name = "PHONE")
	@Mapping("phone")
	private String phone;
	/**
	 * 支付方式
	 */
	@Column(name = "PAY_FLG")
	@Mapping("payFlg")
	private Long payFlg;
	/**
	 * 件数
	 */
	@Column(name = "SUBBILL_PIECE_QTY")
	@Mapping("subbillPieceQty")
	private Long subbillPieceQty;
	/**
	 * 重量
	 */
	@Column(name = "WEIGHT_QTY")
	@Mapping("weightQty")
	private Double weightQty;
	/**
	 * 费用
	 */
	@Column(name = "FEE_AMT")
	@Mapping("feeAmt")
	private Double feeAmt;
	/**
	 * 支持方式，普通COD和短信支付标记，产品类型，产品类型(不同节点代表含义不同)
	 */
	@Column(name = "OTHER_INFO")
	@Mapping("otherInfo")
	private String otherInfo;
	/**
	 * 派件能力值参数
	 */
	@Column(name = "SCHEDULE_CODE")
	@Mapping("scheduleCode")
	private String scheduleCode;
	/**
	 * 费用,金额（COD或者短信支付），轻抛重量，计费重量(不同节点代表含义不同)
	 */
	@Column(name = "ACCOUNTANT_CODE")
	@Mapping("accountantCode")
	private String accountantCode;
	/**
	 * 签收标识
	 */
	@Column(name = "SIGN_TYPE_CODE")
	@Mapping("signTypeCode")
	private String signTypeCode;
	/**
	 * 接驳标识
	 */
	@Column(name = "STOP_OVER_FLG")
	@Mapping("stopOverFlg")
	private Long stopOverFlg;
	/**
	 *特色经济标记，特安标识，包目的地代码(不同节点代表含义不同)
	 */
	@Column(name = "DEST_ZONE_CODE")
	@Mapping("destZoneCode")
	private String destZoneCode;
	/**
	 * 源车标号
	 */
	@Column(name = "SRC_CONTNR_CODE")
	@Mapping("srcContnrCode")
	private String srcContnrCode;
	/**
	 * 车牌号,fvp对象中没有对应的字段
	 */
	@Column(name = "TRUCK_PLATE_CODE")
	private String truckPlateCode;
	/**
	 * 
	 */
	@Column(name = "EXTEND_ATTACH_1")
	@Mapping("extendAttach1")
	private String extendAttach1;
	/**
	 * 
	 */
	@Column(name = "EXTEND_ATTACH_2")
	@Mapping("extendAttach2")
	private String extendAttach2;
	/**
	 * 
	 */
	@Column(name = "EXTEND_ATTACH_3")
	@Mapping("extendAttach3")
	private String extendAttach3;
	/**
	 * 
	 */
	@Column(name = "EXTEND_ATTACH_4")
	@Mapping("extendAttach4")
	private String extendAttach4;
	/**
	 * 
	 */
	@Column(name = "extend_attach_5")
	@Mapping("extendAttach5")
	private String extendAttach5;
	/**
	 * 路由信息的文件名称
	 */
	@Column(name = "FILE_NAME")
	private String fileName; 
	/**
	 * 当前插入时间
	 */
	@Column(name = "INSERT_TIME")
	private Date insertTime; 
	
	/**
	 * 路由状态
	 */
	@Column(name = "STATUS")
	private Integer status; 
	/**
	 * 路由状态修改时间
	 */
	@Column(name = "STATUS_DT")
	private Date statusDt; 
	/**
	 * 代理原始的eventCode
	 */
	@Transient
	private String agentEventCode;
	
	/**
	 * 代理原始的ReasonCode
	 */
	@Transient
	private String agentReasonCode;
	
	@Mapping("barScanTm")
	@Transient
	private Date fvpBarScanTm;
	
	/**
	 * 路由发送次数
	 */
	@Column(name = "send_count")
	private Integer sendCount; 
	
	/**
	 * 路由失败原因
	 */
	@Column(name = "fail_reason")
	private String failReason; 
	
	
	@Column(name="match_time")
	private Date matchTime;
	

	/**
	 * 失败原因集合
	 */
	@Transient
	private List<String> failReasonList = new ArrayList<String>();
	
	/**
	 * 表达式映射字段，用来决定eventCode的数据
	 */
	@Transient
	private Map<String,String> adjustEventCodeInfo = new HashMap<String,String>();
	
	/**
	 * 每条路由信息对应的行号
	 */
	@Transient
	private Integer lineNum;
	
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Date getInsertTime() {
		return insertTime;
	}
	public void setInsertTime(Date insertTime) {
		this.insertTime = insertTime;
	}
	
	public Long getAgentId() {
		return agentId;
	}
	public void setAgentId(Long agentId) {
		this.agentId = agentId;
	}
	
	public String getAgentCode() {
		return agentCode;
	}
	public void setAgentCode(String agentCode) {
		this.agentCode = agentCode;
	}
	public String getNetNum() {
		return netNum;
	}
	public void setNetNum(String netNum) {
		this.netNum = netNum;
	}
	public String getOperatorId() {
		return operatorId;
	}
	public void setOperatorId(String operatorId) {
		this.operatorId = operatorId;
	}
	public String getSfWaybill() {
		return sfWaybill;
	}
	public void setSfWaybill(String sfWaybill) {
		this.sfWaybill = sfWaybill;
	}
	public String getAgentWaybill() {
		return agentWaybill;
	}
	public void setAgentWaybill(String agentWaybill) {
		this.agentWaybill = agentWaybill;
	}
	public Integer getEventCode() {
		return eventCode;
	}
	public void setEventCode(Integer eventCode) {
		this.eventCode = eventCode;
	}
	public Integer getReasonCode() {
		return reasonCode;
	}
	public void setReasonCode(Integer reasonCode) {
		this.reasonCode = reasonCode;
	}
	
	
	public Date getBarTime() {
		return barTime;
	}
	public void setBarTime(Date barTime) {
		this.barTime = barTime;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Date getBarDate() {
		return barDate;
	}
	public void setBarDate(Date barDate) {
		this.barDate = barDate;
	}
	
	public String getBarSn() {
		return barSn;
	}
	public void setBarSn(String barSn) {
		this.barSn = barSn;
	}
	
	public String getAgentEventCode() {
		return agentEventCode;
	}
	public void setAgentEventCode(String agentEventCode) {
		this.agentEventCode = agentEventCode;
	}
	public String getAgentReasonCode() {
		return agentReasonCode;
	}
	public void setAgentReasonCode(String agentReasonCode) {
		this.agentReasonCode = agentReasonCode;
	}
	public Date getFvpBarScanTm() {
		return fvpBarScanTm;
	}
	public void setFvpBarScanTm(Date fvpBarScanTm) {
		this.fvpBarScanTm = fvpBarScanTm;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public Long getBarUploadTypeCode() {
		return barUploadTypeCode;
	}
	public void setBarUploadTypeCode(Long barUploadTypeCode) {
		this.barUploadTypeCode = barUploadTypeCode;
	}
	public String getCourierCode() {
		return courierCode;
	}
	public void setCourierCode(String courierCode) {
		this.courierCode = courierCode;
	}
	public String getEncryptString() {
		return encryptString;
	}
	public void setEncryptString(String encryptString) {
		this.encryptString = encryptString;
	}
	public String getBatchCode() {
		return batchCode;
	}
	public void setBatchCode(String batchCode) {
		this.batchCode = batchCode;
	}
	public String getOpName() {
		return opName;
	}
	public void setOpName(String opName) {
		this.opName = opName;
	}
	public String getOpAttachInfo() {
		return opAttachInfo;
	}
	public void setOpAttachInfo(String opAttachInfo) {
		this.opAttachInfo = opAttachInfo;
	}
	public String getContnrCode() {
		return contnrCode;
	}
	public void setContnrCode(String contnrCode) {
		this.contnrCode = contnrCode;
	}
	public String getPhoneZone() {
		return phoneZone;
	}
	public void setPhoneZone(String phoneZone) {
		this.phoneZone = phoneZone;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public Long getPayFlg() {
		return payFlg;
	}
	public void setPayFlg(Long payFlg) {
		this.payFlg = payFlg;
	}
	public Long getSubbillPieceQty() {
		return subbillPieceQty;
	}
	public void setSubbillPieceQty(Long subbillPieceQty) {
		this.subbillPieceQty = subbillPieceQty;
	}
	public Double getWeightQty() {
		return weightQty;
	}
	public void setWeightQty(Double weightQty) {
		this.weightQty = weightQty;
	}
	public Double getFeeAmt() {
		return feeAmt;
	}
	public void setFeeAmt(Double feeAmt) {
		this.feeAmt = feeAmt;
	}
	public String getOtherInfo() {
		return otherInfo;
	}
	public void setOtherInfo(String otherInfo) {
		this.otherInfo = otherInfo;
	}
	public String getScheduleCode() {
		return scheduleCode;
	}
	public void setScheduleCode(String scheduleCode) {
		this.scheduleCode = scheduleCode;
	}
	public String getAccountantCode() {
		return accountantCode;
	}
	public void setAccountantCode(String accountantCode) {
		this.accountantCode = accountantCode;
	}
	public String getSignTypeCode() {
		return signTypeCode;
	}
	public void setSignTypeCode(String signTypeCode) {
		this.signTypeCode = signTypeCode;
	}
	public Long getStopOverFlg() {
		return stopOverFlg;
	}
	public void setStopOverFlg(Long stopOverFlg) {
		this.stopOverFlg = stopOverFlg;
	}
	public String getDestZoneCode() {
		return destZoneCode;
	}
	public void setDestZoneCode(String destZoneCode) {
		this.destZoneCode = destZoneCode;
	}
	public String getSrcContnrCode() {
		return srcContnrCode;
	}
	public void setSrcContnrCode(String srcContnrCode) {
		this.srcContnrCode = srcContnrCode;
	}
	public String getTruckPlateCode() {
		return truckPlateCode;
	}
	public void setTruckPlateCode(String truckPlateCode) {
		this.truckPlateCode = truckPlateCode;
	}
	public String getExtendAttach1() {
		return extendAttach1;
	}
	public void setExtendAttach1(String extendAttach1) {
		this.extendAttach1 = extendAttach1;
	}
	public String getExtendAttach2() {
		return extendAttach2;
	}
	public void setExtendAttach2(String extendAttach2) {
		this.extendAttach2 = extendAttach2;
	}
	public String getExtendAttach3() {
		return extendAttach3;
	}
	public void setExtendAttach3(String extendAttach3) {
		this.extendAttach3 = extendAttach3;
	}
	public String getExtendAttach4() {
		return extendAttach4;
	}
	public void setExtendAttach4(String extendAttach4) {
		this.extendAttach4 = extendAttach4;
	}
	public String getExtendAttach5() {
		return extendAttach5;
	}
	public void setExtendAttach5(String extendAttach5) {
		this.extendAttach5 = extendAttach5;
	}
	public Date getStatusDt() {
		return statusDt;
	}
	public void setStatusDt(Date statusDt) {
		this.statusDt = statusDt;
	}
		
	public Integer getSendCount() {
		return sendCount;
	}
	public String getFailReason() {
		return failReason;
	}
	public void setSendCount(Integer sendCount) {
		this.sendCount = sendCount;
	}
	public void setFailReason(String failReason) {
		this.failReason = failReason;
	}
	
	public List<String> getFailReasonList() {
		return failReasonList;
	}
	public void addFailReasonList(String failReason) {
		this.failReasonList.add(failReason);
	}

	public void setFailReasonList(List<String> failReasonList) {
		this.failReasonList = failReasonList;
	}
	public Map<String, String> gt() {
		return adjustEventCodeInfo;
	}
	
	public void setAdjustEventCodeInfo(String agentCode,String agentValue) {
		this.adjustEventCodeInfo.put(agentCode, agentValue);
	}
	
	
	public Map<String, String> getAdjustEventCodeInfo() {
		return adjustEventCodeInfo;
	}
	public void setAdjustEventCodeInfo(Map<String, String> adjustEventCodeInfo) {
		this.adjustEventCodeInfo = adjustEventCodeInfo;
	}
	
	
	public Integer getLineNum() {
		return lineNum;
	}
	public void setLineNum(Integer lineNum) {
		this.lineNum = lineNum;
	}
	
	public String getAgentNetNum() {
		return agentNetNum;
	}
	public void setAgentNetNum(String agentNetNum) {
		this.agentNetNum = agentNetNum;
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Router){
			Router router = (Router) obj;
	
			if(this.agentWaybill.equals(router.getAgentWaybill()) && this.eventCode.equals(router.getEventCode())&&
					this.reasonCode == router.getReasonCode()){
				return true;
			}
			
			return false;
		}else{
			
			return false;
		}
	}
	
	@Override
	public int hashCode() {
		
		return this.agentWaybill.hashCode();
	}
	
	@Override
	public String toString() {
		return "Router [id=" + id + ", agentId=" + agentId + ", country="
				+ country + ", sfWaybill=" + sfWaybill + ", agentCode="
				+ agentCode + ", agentWaybill=" + agentWaybill + ", netNum="
				+ netNum + ", operatorId=" + operatorId + ", eventCode="
				+ eventCode + ", reasonCode=" + reasonCode + ", barDate="
				+ barDate + ", barTime=" + barTime + ", barUploadTypeCode="
				+ barUploadTypeCode + ", courierCode=" + courierCode
				+ ", encryptString=" + encryptString + ", barSn=" + barSn
				+ ", batchCode=" + batchCode + ", opName=" + opName
				+ ", opAttachInfo=" + opAttachInfo + ", contnrCode="
				+ contnrCode + ", phoneZone=" + phoneZone + ", phone=" + phone
				+ ", payFlg=" + payFlg + ", subbillPieceQty=" + subbillPieceQty
				+ ", weightQty=" + weightQty + ", feeAmt=" + feeAmt
				+ ", otherInfo=" + otherInfo + ", scheduleCode=" + scheduleCode
				+ ", accountantCode=" + accountantCode + ", signTypeCode="
				+ signTypeCode + ", stopOverFlg=" + stopOverFlg
				+ ", destZoneCode=" + destZoneCode + ", srcContnrCode="
				+ srcContnrCode + ", truckPlateCode=" + truckPlateCode
				+ ", extendAttach1=" + extendAttach1 + ", extendAttach2="
				+ extendAttach2 + ", extendAttach3=" + extendAttach3
				+ ", extendAttach4=" + extendAttach4 + ", extendAttach5="
				+ extendAttach5 + ", fileName=" + fileName + ", insertTime="
				+ insertTime + ", status=" + status + ", statusDt=" + statusDt
				+ ", agentEventCode=" + agentEventCode + ", agentReasonCode="
				+ agentReasonCode + ", fvpBarScanTm=" + fvpBarScanTm + "]";
	}
	
	
	
	
	public static void main(String[] args) throws Exception{
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Date parse = df.parse("2005-10-10");
		Date parse1 = df.parse("2005-10-10");
		DateFormat df1 = new SimpleDateFormat("HH:mm:ss");
		Date parse2 = df1.parse("20:33:22");
		Date parse3 = df1.parse("20:33:22");
		Integer i1 = 100;
		Integer i2 = 1100;
		System.out.println(i1.equals(i2));
		
		List<Router> routerList = new ArrayList<Router>();
		Router router1 = new Router();
		router1.setSfWaybill("111111");
		router1.setEventCode(11);
		router1.setBarDate(parse);
		router1.setBarTime(parse2);
		router1.setStatus(2);
		routerList.add(router1);
		Router router2 = new Router();
		router2.setStatus(2);
		router2.setSfWaybill("111111");
		router2.setEventCode(11);
		router2.setBarDate(parse1);
		router2.setBarTime(parse3);
		routerList.add(router2);
		System.out.println(routerList.size());
		
		Set<Router> routerSet = new HashSet<Router>(routerList);
		System.out.println(routerSet);
	}
	public Date getMatchTime() {
		return matchTime;
	}
	public void setMatchTime(Date matchTime) {
		this.matchTime = matchTime;
	}
		
	
}
